<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>时钟特效</title>
</head>
<body>
<div id="myclock"></div>
<input type="button" value="清除intval" onclick="javascript:clearInterval(intval)">
<input type="button" value="启动intval" onclick="javascript:intval=setInterval('disptime()',1000)">
<script type="text/javascript">
    function disptime() {
        var today=new Date();  //获得当前时间
        var hh=today.getHours();   //获得小时，分钟，秒
        var mm=today.getMinutes();  //获得分钟
        var ss =today.getSeconds();   //获得秒
        //设置div的内容为当前时间
        document.getElementById("myclock").innerHTML="<h1>现在是:"+hh+"时"+mm+"分"+ss+"秒</h1>";
        //myTime=setTimeout("disptime(),1000");//递归
        document.getElementById("myclock").innerHTML+="setInterval id :"+intval;
    };

    //var myTime=setTimeout("disptime(),1000");

    //使用setInterval() 每间隔指定毫秒后调用 disptime()
    disptime();
    var intval=setInterval("disptime()",1000);


    document.write("<h1>对数进行向上舍入\n</h1>"+Math.ceil(35.6));
    document.write("<h1>对数进行向下舍入\n</h1>"+Math.floor(35.6));
    document.write("<h1>对数进行四舍五入\n</h1>"+Math.round(35.6));
    document.write("<h1>对数进行随机数0-1\n</h1>"+Math.random(35.6));
    document.write("<h1>对数进行随机数2-99\n</h1>"+Math.floor(Math.random()*(99-2)+2));


</script>
</body>
</html>